package com.firefly.service.repository.ums;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.firefly.dao.dao.ums.po.RolePermissionPo;
import com.firefly.dao.dao.ums.service.RolePermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;

/**
 * @description: 角色的权限菜单
 * @author: lzg(萤火科技 ： 854378082 @ qq.com)
 * @date: 2022/12/5
 **/
@Repository
public class RolePermissionRepository {
    private final RolePermissionService rolePermissionService;
    @Autowired
    public RolePermissionRepository(RolePermissionService rolePermissionService) {
        this.rolePermissionService = rolePermissionService;
    }
    public Boolean removePrivByRoleId(int id) {
        QueryWrapper<RolePermissionPo> privWrapper = new QueryWrapper<>();
        privWrapper.eq("role_id", id);
        return rolePermissionService.remove(privWrapper);
    }
    public Boolean removePrivByRoleId(List<Integer> ids) {
        QueryWrapper<RolePermissionPo> privWrapper = new QueryWrapper<>();
        privWrapper.in("role_id", ids);
        return rolePermissionService.remove(privWrapper);
    }

    public Boolean insertRolePermission(List<RolePermissionPo> inserts) {
        return rolePermissionService.saveBatch(inserts);
    }
}
